package com.mission.schedule.fragment;

import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.mission.schedule.CommonDialog.CalenderTopCenterDialog;
import com.mission.schedule.CommonDialog.MonthFragmentAddDialog;
import com.mission.schedule.R;
import com.mission.schedule.activity.MainActivity;
import com.mission.schedule.activity.MonthViewActivity;
import com.mission.schedule.activity.NewMyAppSetActivity;
import com.mission.schedule.applcation.App;
import com.mission.schedule.calendar.CaledarAdapter;
import com.mission.schedule.calendar.CalendarBean;
import com.mission.schedule.calendar.CalendarUtil;
import com.mission.schedule.calendar.CalendarView;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.entity.CLRepeatTable;
import com.mission.schedule.entity.ScheduleTable;
import com.mission.schedule.utils.BetterHighlightSpan;
import com.mission.schedule.utils.DateUtil;
import com.mission.schedule.utils.SharedPrefUtil;
import com.mission.schedule.utils.Utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.mission.schedule.calendar.CalendarFactory.getMonthOfDayList;

/**
 * Created by liwei on 19/03/2018.
 */

public class MonthViewFragment extends Fragment implements CalendarView.OnItemClickListener {

    private TextView mTitle, month_tv, year_tv;
    LinearLayout top_ll_left_m;
    String today;
    private boolean isCreat = false;
    int colorss[] = {R.color.white, R.color.color_m_1, R.color.color_m_2, R.color.color_m_3, R.color.color_m_4, R.color.color_m_5};
    SharedPrefUtil sharedPrefUtil = null;
    List<Map<String, String>> queryAllChongFuData = new ArrayList<>();
    int width = 0;
    int height = 0;
    CalendarView calenderView;
    ArrayList<Map<String, String>> dblists = new ArrayList<>();
    ArrayList<Map<String, String>> ulists = new ArrayList<>();
    List<Map<String, String>> calenders = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.month_view_fragment, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        isCreat = true;
        localBroadcastManager = LocalBroadcastManager.getInstance(getActivity());
        sharedPrefUtil = new SharedPrefUtil(getActivity(), ShareFile.USERFILE);

        today = DateUtil.formatDate(new Date());

        mTitle = view.findViewById(R.id.mTitle);
        top_ll_left_m = view.findViewById(R.id.top_ll_left_m);
        month_tv = view.findViewById(R.id.month_tv);
        year_tv = view.findViewById(R.id.year_tv);

        width = getResources().getDisplayMetrics().widthPixels / 7;
        height = getResources().getDisplayMetrics().widthPixels;

        try {
            loaddata();
        } catch (Exception e) {
            e.printStackTrace();
        }
        calenders = App.getDBcApplication().queryNOTHOLIDAYs();

        calenderView = view.findViewById(R.id.calenderView);
        int[] dateArr = CalendarUtil.getYMD(new Date());
        standard_year = dateArr[0];
        standard_month = dateArr[1];
        calenderView.setOnItemClickListener(this);
        calenderView.setAdapter(adapter);
        calenderView.setHandler(handler);
        synchronized (getActivity()) {
            calenderView.setData(getMonthOfDayList(dateArr[0], dateArr[1]), true);
        }
        month_tv.setText(DateUtil.nowMonth());
        year_tv.setText("月/" + DateUtil.nowYear());

        top_ll_left_m.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                int[] dateArr = CalendarUtil.getYMD(new Date());
                standard_year = dateArr[0];
                standard_month = dateArr[1];
                month_tv.setText(DateUtil.nowMonth());
                year_tv.setText("月/" + DateUtil.nowYear());
                calenderView.setData(getMonthOfDayList(dateArr[0], dateArr[1]), true);
                return true;
            }
        });

        mTitle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CalenderTopCenterDialog dialog = new CalenderTopCenterDialog(getActivity(), R.style.dialog_translucent_top, getActivity().getWindowManager());
                dialog.show();
                dialog.setCallBack(new CalenderTopCenterDialog.CallBack() {
                    @Override
                    public void setType(int index, String title) {
                        if (index == 0) {
                            sharedPrefUtil.putString(getActivity(), ShareFile.USERFILE, ShareFile.LOCALPATH, "1");
                        } else {
                            sharedPrefUtil.putString(getActivity(), ShareFile.USERFILE, ShareFile.LOCALPATH, "0");
                        }
                        sharedPrefUtil.putString(getActivity(), ShareFile.USERFILE, ShareFile.TYPEINDEX, index + "");
                        sharedPrefUtil.putString(getActivity(), ShareFile.USERFILE, ShareFile.TYPETITLE, title);
                        MainActivity.instance.setmainbg();
                        try {
                            loaddata();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        Intent intent = new Intent("noticeOnRefresh");
                        localBroadcastManager.sendBroadcast(intent);
                    }
                });
            }
        });
    }

    LocalBroadcastManager localBroadcastManager;

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        if (getUserVisibleHint() && isCreat) {// && !isShow
            if (sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.IS_MONTH_RE, "1").equals("1")) {
                try {
                    loaddata();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }


    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser && isCreat) {

        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.IS_MONTH_RE, "1").equals("1")) {
            try {
                loaddata();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    int standard_year;
    int standard_month;
    Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (msg == null) {
                return;
            }
            switch (msg.what) {
                case 0:
                    if (standard_month == 1) {
                        standard_month = 12;
                        standard_year--;
                    } else {
                        standard_month--;
                    }
//                    mTitle.setText(standard_year + "年" + (standard_month > 9 ? standard_month : "0"+standard_month)  + "月");
                    month_tv.setText("" + (standard_month > 9 ? standard_month : "0" + standard_month));
                    year_tv.setText("月/" + standard_year);
                    calenderView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.right_in));
                    calenderView.setData(getMonthOfDayList(standard_year, standard_month), true);

                    break;

                case 1:
                    if (standard_month == 12) {
                        standard_month = 1;
                        standard_year++;
                    } else {
                        standard_month++;
                    }
//                    mTitle.setText(standard_year + "年" + (standard_month > 9 ? standard_month : "0"+standard_month)  + "月");
                    month_tv.setText("" + (standard_month > 9 ? standard_month : "0" + standard_month));
                    year_tv.setText("月/" + standard_year);
                    calenderView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.left_in));
                    calenderView.setData(getMonthOfDayList(standard_year, standard_month), true);

                    break;
            }
        }
    };

    CaledarAdapter adapter = new CaledarAdapter() {
        @Override
        public View getView(View convertView, ViewGroup parentView, final CalendarBean bean) {
            //判断convertView为null，可以有效利用view的回收重用，左右滑动的效率高
            //mothFlag 0是当月，-1是月前，1是月后
            if (convertView == null) {
                convertView = LayoutInflater.from(parentView.getContext()).inflate(R.layout.month_view_fragment_item, null);
            }
            final TextView calender_tv = convertView.findViewById(R.id.calender_tv);
            calender_tv.setText("");
            TextView chinaText = convertView.findViewById(R.id.no);
            chinaText.setText("");
            chinaText.setTextColor(getResources().getColor(R.color.gongkai_txt));
            TextView text = convertView.findViewById(R.id.number);
            text.setText("");
            text.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            text.setTextColor(getResources().getColor(R.color.gongkai_txt));
            RelativeLayout today_ll = convertView.findViewById(R.id.today_ll);
            today_ll.setBackground(getActivity().getResources().getDrawable(R.drawable.calender_white));

            String month = bean.moth + "";
            String day = bean.day + "";

            if (bean.moth < 10) {
                month = "0" + bean.moth;
            }

            if (bean.day < 10) {
                day = "0" + bean.day;
            }

            final String selected_day = bean.year + "-" + month + "-" + day;
            if (bean.mothFlag == 0) {
                text.setText("" + bean.day);
                calender_tv.setTextColor(Color.BLACK);
                String lunar_holiday = "";
                for (Map<String, String> map : calenders) {
                    if (map.get("calender").equals(selected_day)) {
                        lunar_holiday = map.get("LUNAR_HOLIDAY");
                        break;
                    }
                }
                if (lunar_holiday.isEmpty()) {
                    chinaText.setText(bean.chinaDay);
                } else {
                    chinaText.setText(lunar_holiday);
                }

                int numbers = Utils.pxTodip(getActivity(), width - Utils.dipTopx(getActivity(), 10)) / 9;
                int lines = Utils.pxTodip(getActivity(), height - Utils.dipTopx(getActivity(), 120)) / 7 / 9 + 1;

                StringBuilder contents = new StringBuilder();
                List<Map<String, String>> dblist = new ArrayList<>();
                List<Map<String, String>> ulist = new ArrayList<>();
                List<Map<String, String>> list = new ArrayList<>();
                List<Map<String, String>> newlist = new ArrayList<>();
                List<Map<String, String>> newulist = new ArrayList<>();

                for (Map<String, String> map : dblists) {
                    if (map.get(ScheduleTable.schDate).equals(selected_day)) {
                        dblist.add(map);
                    }
                }


                for (Map<String, String> mMap : ulists) {
                    if (mMap.get(ScheduleTable.schDate).equals(selected_day)) {
                        if (!"0".equals(mMap.get(ScheduleTable.schRepeatID)) && !"0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
                            String type = App.getDBcApplication().queryRepateType(mMap.get(ScheduleTable.schRepeatID)).get("type");
                            if (!"1".equals(type) && !"5".equals(type)) {
                                ulist.add(mMap);
                            }
                        } else {
                            ulist.add(mMap);
                        }
                        if (dblist.size() > 0) {
                            if (ulist.size() >= lines - 1) {
                                break;
                            }
                        }
                    }
                }

                newlist.addAll(dblist);
                newlist.addAll(ulist);
                for (Map<String, String> mMap : newlist) {
                    if (!"0".equals(mMap.get(ScheduleTable.schRepeatID)) && !"0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
                        String type = App.getDBcApplication().queryRepateType(mMap.get(ScheduleTable.schRepeatID)).get("type");
                        if (!"1".equals(type) && !"5".equals(type)) {
                            list.add(mMap);
                        }
                    } else {
                        list.add(mMap);
                    }
                }
//                for (Map<String, String> mMap : ulist) {
//                    if (!"0".equals(mMap.get(ScheduleTable.schRepeatID)) && !"0".equals(mMap.get(ScheduleTable.schRepeatLink))) {
//                        String type = App.getDBcApplication().queryRepateType(mMap.get(ScheduleTable.schRepeatID)).get("type");
//                        if (!"1".equals(type) && !"5".equals(type)) {
//                            newulist.add(mMap);
//                        }
//                    } else {
//                        newulist.add(mMap);
//                    }
//                }
                List<String> colors = new ArrayList<>();
                if (selected_day.equals(today) && bean.mothFlag == 0) {
                    if (dblist.size() > 0) {
                        contents = new StringBuilder("待办(" + dblist.size() + ")\n");
                        colors.add("0");
                    }
                    for (int i = 0; i < ulist.size(); i++) {
                        Map<String, String> map = ulist.get(i);
                        if (i < lines - 1) {
                            String content = map.get(ScheduleTable.schContent);
                            if (content.length() > numbers) {
                                content = content.substring(0, numbers);
                            }
                            contents.append(content).append("\n");
                            colors.add(map.get(ScheduleTable.schRemark11));
                        }
                    }
                } else {
                    for (int i = 0; i < list.size(); i++) {
                        Map<String, String> map = list.get(i);
                        if (i < lines) {
                            String content = map.get(ScheduleTable.schContent);
                            if (content.length() > numbers) {
                                content = content.substring(0, numbers);
                            }
                            contents.append(content).append("\n");
                            colors.add(map.get(ScheduleTable.schRemark11));
                        }
                    }
                }

                int s_i = 0;
                for (Map<String, String> mMap : queryAllChongFuData) {
                    String content = mMap.get(CLRepeatTable.repContent);
                    if (content.length() > numbers) {
                        content = content.substring(0, numbers);
                    }

                    int cl = contents.toString().isEmpty() ? 0 : contents.toString().split("\n").length;

                    // 每周
                    if (s_i <= lines - cl) {
                        if (mMap.get(CLRepeatTable.repType).equals("2")) {
                            int days = DateUtil.days(mMap.get(CLRepeatTable.repNextCreatedTime), selected_day);
                            if (days > 0 && days % 7 == 0) {
                                contents.append(content).append("\n");
                                colors.add("-1");
                                s_i++;
                            }
                        }
                        if (mMap.get(CLRepeatTable.repType).equals("3")) {
                            int days = DateUtil.days(mMap.get(CLRepeatTable.repNextCreatedTime), selected_day);
                            String repTypeParameter = mMap.get(CLRepeatTable.repTypeParameter).replace("[", "").replace("]", "").replace("\"", "");
                            if (days > 0 && repTypeParameter.equals(day)) {
                                contents.append(content).append("\n");
                                colors.add("-1");
                                s_i++;
                            }
                        }

                        if (mMap.get(CLRepeatTable.repType).equals("4")) {
                            int days = DateUtil.days(mMap.get(CLRepeatTable.repNextCreatedTime), selected_day);
                            String repTypeParameter = mMap.get(CLRepeatTable.repTypeParameter).replace("[", "").replace("]", "").replace("\"", "");
                            if (days > 0 && repTypeParameter.equals(month + "-" + day)) {
                                contents.append(content).append("\n");
                                colors.add("-1");
                                s_i++;
                            }
                        }
//                        if (mMap.get(CLRepeatTable.repType).equals("6")) {
//                            String repTypeParameter = mMap.get(CLRepeatTable.repTypeParameter).replace("[", "").replace("]", "").replace("\"", "");
//                            String n_month = repTypeParameter.replace("1", "").replace("十一月", "冬月").replace("十二月", "腊月");
//                            List<Map<String, String>> solarList = App.getDBcApplication().queryNearLunartoSolarList(n_month);
//                            if (solarList.size() > 0) {
//                                int days = DateUtil.days(mMap.get(CLRepeatTable.repNextCreatedTime), selected_day);
//                                mMap = solarList.get(0);
//                                if (days > 0 && mMap.get("calendar").equals(selected_day)) {
//                                    contents.append(content).append("\n");
//                                    colors.add("-1");
//                                    s_i++;
//                                }
//                            }
//                        }
                    }
                }

                int days = DateUtil.days(selected_day);
                if (days >= 0) {
                    SpannableStringBuilder style = new SpannableStringBuilder(contents.toString());
                    String contentss[] = contents.toString().split("\n");
                    int start = 0;
                    int end = 0;
                    for (int i = 0; i < colors.size(); i++) {
                        if (i == colors.size() - 1) {
                            end += contentss[i].length();
                        } else {
                            end += contentss[i].length() + 1;
                        }
                        String remark11 = colors.get(i) == null ? "0" : colors.get(i);
                        if (remark11.equals("")) {
                            remark11 = "0";
                        }
                        int color = Integer.valueOf(remark11);
                        if (color > 0) {
                            style.setSpan(new BetterHighlightSpan(
                                            getActivity().getResources().getColor(colorss[color]),
                                            color > 2 ? Color.WHITE : Color.BLACK
                                            , Utils.dipTopx(getActivity(), 11)), start, end,
                                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
                        } else if (color < 0) {
                            style.setSpan(new ForegroundColorSpan(getActivity().getResources().getColor(R.color.gongkai_txt3)), start, end,
                                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
                        }
                        start += contentss[i].length() + 1;

                    }
                    calender_tv.setText(style);
                } else {
                    calender_tv.setText(contents.toString());
                    calender_tv.setTextColor(getActivity().getResources().getColor(R.color.gongkai_txt3));
                }
            }


            if (selected_day.equals(today) && bean.mothFlag == 0) {
                text.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
                text.setTextColor(Color.WHITE);
                chinaText.setTextColor(Color.WHITE);
                today_ll.setBackground(getActivity().getResources().getDrawable(R.drawable.red_round_fill));
            }

            return convertView;
        }
    };

    @Override
    public void onItemClick(View view, int postion, CalendarBean bean) {
        if (sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.TYPEUID, "").isEmpty()) {
            if (bean.mothFlag == 0) {
                String month = bean.moth + "";
                String day = bean.day + "";
                if (bean.moth < 10) {
                    month = "0" + bean.moth;
                }

                if (bean.day < 10) {
                    day = "0" + bean.day;
                }

                final String selected_day = bean.year + "-" + month + "-" + day;
                MonthFragmentAddDialog dialog = new MonthFragmentAddDialog(getActivity(),
                        R.style.dialog_translucent, getActivity().getWindowManager(), selected_day, newopeartTypes);
                dialog.show();
                dialog.setCallBack(new MonthFragmentAddDialog.CallBack() {
                    @Override
                    public void reminderEditTime() {
                        try {
                            loaddata();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        month_tv.setText("" + (standard_month > 9 ? standard_month : "0" + standard_month));
                        year_tv.setText("月/" + standard_year);
                        calenderView.setData(getMonthOfDayList(standard_year, standard_month), true);
                    }
                });
            }
        }
    }

    @Override
    public void onLongItemClick(View view, int postion, CalendarBean bean) {
        if (bean.mothFlag == 0) {
            String month = bean.moth + "";
            String day = bean.day + "";
            if (bean.moth < 10) {
                month = "0" + bean.moth;
            }

            if (bean.day < 10) {
                day = "0" + bean.day;
            }

            final String selected_day = bean.year + "-" + month + "-" + day;
            ArrayList<Map<String, String>> intentmaplist = new ArrayList<>();
            for (Map<String, String> map : ulists) {
                if (map.get(ScheduleTable.schDate).equals(selected_day)) {
                    intentmaplist.add(map);
                }
            }
            for (Map<String, String> map : dblists) {
                if (map.get(ScheduleTable.schDate).equals(selected_day)) {
                    intentmaplist.add(map);
                }
            }
//            if (intentmaplist.size() > 0) {
                Intent intent = new Intent(getActivity(), MonthViewActivity.class);
                intent.putExtra("date", selected_day);
                intent.putExtra("newopeartType", newopeartTypes);
                startActivity(intent);
//            }
        }
    }

    int newopeartTypes = 0;

    private void loaddata() throws Exception {
        String index = sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.TYPEINDEX, "3");
        if (index == null && index.equals("")) {
            index = "0";
        }
        String newtitle = sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.TYPETITLE, "我的日程");
        int newopeartType = Integer.valueOf(index);
        if (newopeartType < 0) {
            mTitle.setText(newtitle);
        } else {
            mTitle.setText("我的日程");
        }
        newopeartTypes = newopeartType;
        ulists.clear();
        dblists.clear();
        queryAllChongFuData.clear();
        switch (newopeartType) {
            case -1://以前
                ulists.addAll(App.getDBcApplication().queryAllSchData(22, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(23, 0, 0));
                break;
            case -2:
                ulists.addAll(App.getDBcApplication().queryAllSchData(25, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(26, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(27, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(28, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(29, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(30, 0, 0));
                break;
            case -3:
                ulists.addAll(App.getDBcApplication().queryAllSchData(-6, 0, 0));
                break;
            case -4:
                ulists.addAll(App.getDBcApplication().queryAllSchData(66, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(67, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(68, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(69, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(70, 0, 0));
                ulists.addAll(App.getDBcApplication().queryAllSchData(71, 0, 0));
                break;
            case -6:
            case -7:
            case -8:
            case -9:
            case -10:
            case -11:
            case -12:
                newopeartType = Math.abs(newopeartType) - 5;

                ulists.addAll(App.getDBcApplication().queryAllSchData(50, 0, newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(51, 0, newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(52, 0, newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(53, 0, newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(54, 0, newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(55, 0, newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(50, 0, 100 + newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(51, 0, 100 + newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(52, 0, 100 + newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(53, 0, 100 + newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(54, 0, 100 + newopeartType));
                ulists.addAll(App.getDBcApplication().queryAllSchData(55, 0, 100 + newopeartType));

                break;
            default:
                if (!sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.TYPEUID, "").isEmpty()) {
                    String uid = sharedPrefUtil.getString(getActivity(), ShareFile.USERFILE, ShareFile.TYPEUID, "9999991");
                    ulists = App.getDBcApplication().queryCalenderData("", Integer.valueOf(uid));
                } else {
                    queryAllChongFuData = App.getDBcApplication().QueryAllChongFuData(9);
                    dblists = App.getDBcApplication().queryCalenderData("", 1);
                    ulists = App.getDBcApplication().queryCalenderData("", 0);
                }
                break;
        }
        int[] dateArr = CalendarUtil.getYMD(new Date());
        synchronized (getActivity()) {
            calenderView.setData(getMonthOfDayList(dateArr[0], dateArr[1]), true);
        }
        sharedPrefUtil.putString(getActivity(), ShareFile.USERFILE, ShareFile.IS_MONTH_RE, "0");
    }
}
